package team.you.ticket.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import team.you.ticket.pojo.Result;
import team.you.ticket.pojo.TrainNum;
import team.you.ticket.service.TrainNumService;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Controller
@RequestMapping("/trainNumInfo")
public class TrainNumCtrl {

    @Autowired
    private TrainNumService trainNumService;

    @RequestMapping("/getAllTrainNums")
    @ResponseBody
    private Result getAllTrainNums(Integer page,Integer limit)
    {
        return trainNumService.getAllTrainNums(page,limit);
    }
    @RequestMapping("/selectByLike")
    @ResponseBody
    private Result selectByLike(String value, String type,Integer page,Integer limit)
    {
        if (type=="")
            type="3";
        return trainNumService.selectByLike(value,type,page,limit);
    }
    @RequestMapping("/selectByTime")
    @ResponseBody
    private Result selectByTime(String time,Integer page,Integer limit)
    {
        return trainNumService.selectByTime(time,page,limit);
    }
    @RequestMapping("/add")
    @ResponseBody
    private Result add(TrainNum trainNum)
    {
        return trainNumService.add(trainNum);
    }
    @RequestMapping("/getCarId")
    @ResponseBody
    private Result getCarId()
    {
        return trainNumService.getCarId();
    }
    @RequestMapping("/del")
    @ResponseBody
    private Result del(String id)
    {
        return trainNumService.del(id);
    }
    @RequestMapping("/delete")
    @ResponseBody
    private Result delete(String[] ids)
    {
        return trainNumService.delete(ids);
    }
    @RequestMapping("/update")
    @ResponseBody
    private Result update(String id,String value,String field)
    {
        return trainNumService.update(id,value,field);
    }
    @RequestMapping("/getAll")
    @ResponseBody
    private Result getAll(String starSite, String endSite, Date time,Integer page, Integer limit)
    {
        return trainNumService.getAll(starSite,endSite,time,page,limit);
    }
}
